package com.wf.ew.system.service.impl;

import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.system.model.User;
import com.wf.ew.system.biz.BugBiz;
import com.wf.ew.system.model.Bug;
import com.wf.ew.system.service.BugService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;

/**
 *
 * 数据服务层接口实现类
 * @author : Doman
 * @date : 2019-12-26 10:52:50
 * @version ：1.0
 */
@Service
public class BugServiceImpl implements BugService {

	@Autowired
	private BugBiz bugBiz;

	@Override
	public String list(PageResult<T> page, Bug bug, User loginUser) {
		return bugBiz.list(page,bug,loginUser);
	}
	
	@Override
	public List<Bug> list(Bug bug, User loginUser) {
		return bugBiz.list(bug,loginUser);
	}

	@Override
	public Bug getById(Bug bug) {
		return bugBiz.getById(bug);
	}

	@Transactional
	@Override
	public JsonResult add(Bug bug, User loginUser) {
		if (bugBiz.add(bug, loginUser)) {
			return JsonResult.ok("添加成功");
		}
		return JsonResult.error("添加失败");
	}

	@Transactional
	@Override
	public JsonResult update(Bug bug, User loginUser) {
		if (bugBiz.update(bug, loginUser)) {
			return JsonResult.ok("修改成功");
		}
		return JsonResult.error("修改失败");
	}

	@Transactional
	@Override
	public JsonResult delete(Bug bug, User loginUser) {
		if (bugBiz.delete(bug, loginUser)) {
			return JsonResult.ok("删除成功");
		}
		return JsonResult.error("删除失败");
	}
}
